Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Python Matplotlib Interview Questions and Answers

Question: What is the purpose of `plt.legend()` in Matplotlib?
Answer: `plt.legend()` is used to add a legend to the plot, providing information about the plotted data series.

Example:

plt.plot([1, 2, 3, 4], [10, 20, 25, 30], label='Line 1')
plt.legend()
plt.show()
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook